package com.xishu.entity.customer;

import com.xishu.annotation.dao.DefaultValue;
import com.xishu.annotation.dao.Search;
import com.xishu.annotation.oplog.OplogAnnotation;
import com.xishu.entity.AbstractEntity;
import com.xishu.entity.shop.DiscountTicket;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import javax.persistence.Transient;

@Api(description = "会员拥有的优惠卷")
@Entity(name = "customer_ticket")
@Table(indexes = {@Index(columnList = "expiredTime")})
@Data
public class CustomerTicket extends AbstractEntity {
    @ApiModelProperty(value = "公司ID")
    private Long companyId;

    @ApiModelProperty(value = "会员")
    private Long customerId;

    @ApiModelProperty(value = "优惠卷ID")
    private Long ticketId;

    @ApiModelProperty(value = "优惠卷的CODE")
    private String code;

    @ApiModelProperty(value = "是否是VIP类型的优惠卷")
    private Boolean vip;

    @ApiModelProperty(value = "优惠卷的父ID，方便做统一的更新和删除")
    private Long parentTicketId;

    @ApiModelProperty(value = "是否已经使用")
    @DefaultValue(defaultValue = "false")
    private Boolean used;

    @ApiModelProperty(value = "过期时间")
    private Long expiredTime;

    @ApiModelProperty(value = "过期时间")
    private String expiredDate;

    @ApiModelProperty(value = "哪一个支付订单产生的优惠")
    private Long orderId;

    @ApiModelProperty(value = "是否限量,如果是false不限量，那么在使用过后，需要再发送一张优惠券")
    private Boolean limitNumber;

    @Transient
    @ApiModelProperty(value = "优惠卷的名称")
    @OplogAnnotation(fieldName = "优惠卷的名称")
    private String ticketName_zh;

    @Transient
    @ApiModelProperty(value = "优惠卷的名称")
    @OplogAnnotation(fieldName = "优惠卷的名称")
    private String ticketName_en;

    @Transient
    @ApiModelProperty(value = "开始的过期时间")
    @Search(gte = true, fieldName = "expiredTime")
    private Long startExpiredTime;

    @Transient
    @ApiModelProperty(value = "结束的过期时间，查询优惠券已过期，需要用的条件是小于当前的时间")
    @Search(lte = true, fieldName = "expiredTime")
    private Long endExpiredTime;

    @ApiModelProperty(value = "是否已过期，由服务器计算出来")
    @DefaultValue(defaultValue = "false")
    private Boolean expired;

    @Transient
    @ApiModelProperty(value = "优惠券本身的信息")
    private DiscountTicket discountTicket;

    @ApiModelProperty(value = "会员等级优惠券ID")
    private Long levelTicketId;

    @ApiModelProperty(value = "对应的等级")
    private Long levelId;

    @ApiModelProperty(value = "通过excel导入")
    @DefaultValue(defaultValue = "false")
    private Boolean assignByExcel;

}
